/**
 * 
 */
package neptune.web.client.view.components.editor;

import neptune.web.client.model.topology.SerializableNode;
import neptune.web.client.model.topology.SerializableTopology;

import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.TreeItem;

/**
 * 
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 * 
 */
public class NodeMenuBar extends MenuBar {

	private MenuItem rootItem;

	public NodeMenuBar(SerializableNode node, SerializableTopology topology,
			TreeItem item, TopologyEditor editor) {
		super(false);
		MenuItem props = new MenuItem("Properties", new NodePropsCommand(node,
				item, editor));
		MenuItem addNi = new MenuItem("Add NetInterface", new AddNetIFCommand(
				node, topology, item));
		MenuItem addSoft = new MenuItem("Add Software", new AddSoftwareCommand(
				node, item));
		MenuItem removeNode = new MenuItem("Remove", new RemoveNodeCommand(
				topology, node, item, editor));

		MenuBar options = new MenuBar(true);

		options.addItem(props);
		options.addItem(addNi);
		options.addItem(addSoft);
		options.addItem(removeNode);

		rootItem = new MenuItem(node.getId(), options);
		addItem(rootItem);
		options.setStylePrimaryName("TopologyEditor-tree-NodeItem");
		this.setStylePrimaryName("TopologyEditor-tree-RootNodeItem");
	}

	/**
	 * @return the rootItem
	 */
	public MenuItem getRootItem() {
		return rootItem;
	}

}